{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "## Matplotlib 直方图\n",
    "### 创建直方图\n",
    "直方图是显示 频率 分布的图形。\n",
    "它是一个图表，显示每个给定间隔内的观察次数。\n",
    "\n",
    "使用 hist() 函数创建直方图\n",
    "hist() 函数将使用数字数组创建直方图，该数组作为参数带入到函数中"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "outputs": [
    {
     "data": {
      "text/plain": "<Figure size 640x480 with 1 Axes>",
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/H5lhTAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAdHklEQVR4nO3df3RX9X348VdifoBCPjQIiRkJ6FxF7aCn1EE2Z1eaCRyPw5Kegx7WoYfZ0y6wSjY7s7V17uwcsF1F24Pa04NaT8fcOGdaqae4nrSE9jQ4jeNUW5uqswMLCRsuCdASMnO/f3j8fPuRKCaEd0h4PM6555h77+d+3nmfK3nm5n4+n6Isy7IAAEikeKwHAACcXcQHAJCU+AAAkhIfAEBS4gMASEp8AABJiQ8AICnxAQAkVTLWA3irwcHB2L9/f0ydOjWKiorGejgAwLuQZVkcPnw4ampqorj4na9tnHHxsX///qitrR3rYQAAI7Bv376YNWvWO+5zxsXH1KlTI+KNwVdUVIzxaACAd6Ovry9qa2vzP8ffyRkXH2/+qaWiokJ8AMA4825umXDDKQCQlPgAAJISHwBAUuIDAEhKfAAASYkPACAp8QEAJCU+AICkxAcAkJT4AACSEh8AQFLiAwBISnwAAEmJDwAgqZKxHgBwdplz2xNjPYRh+/nGa8Z6CDChuPIBACQlPgCApMQHAJCU+AAAkhIfAEBS4gMASEp8AABJiQ8AICnxAQAkJT4AgKTEBwCQlPgAAJISHwBA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iLq6unjuuefi05/+dFx33XX5G3XP1nkbdWP9cpvT4Xvf+14WEScsq1evHnL/t77UNsuy7NChQ9kNN9yQTZkyJauoqMhuuumm7PDhw6d/8GPsnebul7/8ZXb11VdnM2bMyEpLS7PZs2dnN998c9bV1VVwjLNx7t7NObdly5bs4osvziZNmpTNnz8/e+yxxwqO8atf/Sr7sz/7s+w973lPdu6552Yf/ehHswMHDiT+TtJ7N3P31a9+NZs8eXLW09Mz5DGccyfO24EDB7Ibb7wxq6mpySZNmpRdcskl2Ze+9KVscHAwf4yz8Zw72bzdc8892axZs7LS0tKsrq4u++xnP5v19/cXHONsnLfRVpRl7qIBANI56+75AADGlvgAAJISHwBAUuIDAEhKfAAASYkPACAp8QEAJCU+AICkxAcAkJT4AACSEh8AQFLiAwBI6v8BJ3WUkNWETdcAAAAASUVORK5CYII="
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 一个简单的直方图\n",
    "# 随机生成一个包含 250 个值的数组，其中值将集中在 170 左右，标准偏差为 10\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "x = np.random.normal(170, 10, 250)\n",
    "\n",
    "plt.hist(x)\n",
    "plt.show()"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}